//
//  ViewController.m
//  26-Masonry
//
//  Created by Snow on 16/8/18.
//  Copyright © 2016年 Snow. All rights reserved.
//

#import "ViewController.h"
#import "Masonry.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    //1.使用masonry, 不用给初始frame
    UIView *view = [UIView new];
    //注意.添加约束前, 需要把视图添加到父视图上
    [self.view addSubview:view];
    view.backgroundColor = [UIColor redColor];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    //2.添加一个蓝色的视图 宽高100 居中显示
    UIView *view1 = [UIView new];
    [self.view addSubview:view1];
    view1.backgroundColor = [UIColor blueColor];
    [view1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(self.view.mas_height).multipliedBy(0.2333);
        make.centerX.mas_equalTo(0);
        make.centerY.mas_equalTo(0);
    }];
    
    UIView *greenView = [UIView new];
    [self.view addSubview:greenView];
    greenView.backgroundColor = [UIColor greenColor];
    [greenView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(view1.mas_bottom).mas_equalTo(10);
        make.width.mas_equalTo(view1.mas_width);
        make.height.mas_equalTo(view1.mas_height);
        make.centerX.mas_equalTo(view1.mas_centerX);
    }];
    //greenview.left = self.view.left * 1.0f + 0;
    [NSLayoutConstraint constraintWithItem:greenView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeft multiplier:1 constant:0];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
